import request from '@/utils/request';
import { getToken } from '@/utils/auth';
// 新增问答
const headers = {
  Authorization: `Bearer ${getToken()}`, // 根据实际token格式调整
};
// 查询问答记录列表
export function listRecord(query) {
  return request({
    url: '/bigmodel/questionrecord/list',
    method: 'get',
    port: 'yy',
    params: query,
  });
}

// 查询问答记录详细
export function getRecord(id) {
  return request({
    url: `/bigmodel/questionrecord/${id}`,
    method: 'get',
    port: 'yy',
  });
}

// 新增问答记录/反馈记录
export function addRecord(data) {
  return request({
    url: '/bigmodel/questionrecord',
    method: 'post',
    port: 'yy',
    data,
    headers,
  });
}

// 修改问答记录
export function updateRecord(data) {
  return request({
    url: '/bigmodel/questionrecord',
    method: 'put',
    port: 'yy',
    data,
  });
}

// 删除问答记录
export function delRecord(id) {
  return request({
    url: `/bigmodel/questionrecord/${id}`,
    port: 'yy',
    method: 'delete',
  });
}

// 向ai提问
export function BaiduAI(data) {
  return request({
    url: '/bigmodel/questionrecord/sendQuestion',
    method: 'post',
    port: 'yy',
    data,
    headers,
  });
}

// 生成新对话id
export function startConversation() {
  return request({
    url: '/chat/startConversation',
    port: 'yy',
    method: 'post',
    headers,
  });
}

// 文字转语音
export function textToSpeech(data) {
  return request({
    url: '/chat/textToSpeech',
    data,
    port: 'yy',
    method: 'post',
    headers,
    responseType: 'blob',
  });
}
